package com.smt.ejb3.tutoria.client;

import javax.jms.Destination;
import javax.jms.MessageProducer;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSession;
import javax.naming.InitialContext;

public class QueueSender {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			InitialContext ctx = new InitialContext();
			QueueConnectionFactory factory = (QueueConnectionFactory) ctx
					.lookup("ConnectionFactory");
			QueueConnection conn = factory.createQueueConnection();
			QueueSession session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
			Destination dest = (Destination)ctx.lookup("queue/ejb3destQueue");
			MessageProducer producer = session.createProducer(dest);
			producer.send(session.createTextMessage("hello, this is my first mdb"));
			System.out.println("Message sent");
			session.close();
			conn.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

}
